package pl.prv.polanie.client.panels.lists;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.VerticalPanel;

public class SemestersList extends VerticalPanel {

	FlexTable ft = new FlexTable();
	Button addRecordButton = new Button("Add");
	
	public SemestersList() {
		
		
		
		
//		CSSemesterDTO[] semesters = Cache.getAllSemesters();
//		
//		StudiesTypeDTO[] studiesTypes = Cache.getAllStudiesTypes();
//		SemesterTypeDTO[] semesterTypes = Cache.getAllSemesterTypes();
//		YearNumberDTO[] yearNumbers = Cache.getAllYearNumbers();
//		
//		
//		getInstance().add(ft);
//		
//		
//		for (int i = 0; i < semesters.length; i++) {
//			
//			//STUDIES TYPE
//			long studiesTypeID = semesters[i].getStudiesType().getId();
//			LabelUTextBox studiesTypeslb = new LabelUTextBox();
//			
//			for (int j = 0; j < studiesTypes.length; j++) {
//				studiesTypeslb.addItem(studiesTypes[j].getName(), ""+studiesTypes[j].getId());
//				
//				//wybieramy odpowiedni studies type
//				if (studiesTypeID == studiesTypes[j].getId()) {
//					studiesTypeslb.setSelectedIndex(j);
//				}
//			}
//			
//			
//			
//			//SEMESTER TYPE
//			long semesterTypeID = semesters[i].getSemesterType().getId();
//			LabelUTextBox semesterTypeslb = new LabelUTextBox();
//			
//			for (int j = 0; j < semesterTypes.length; j++) {
//				semesterTypeslb.addItem(semesterTypes[j].getName(), ""+semesterTypes[j].getId());
//				
//				//wybieramy odpowiedni semester type
//				if (semesterTypeID == semesterTypes[j].getId()) {
//					semesterTypeslb.setSelectedIndex(j);
//				}
//			}
//			
//			
//			
//			//SEMESTER TYPE
//			long yearNumberID = semesters[i].getYearNumber().getId();
//			LabelUTextBox yearNumberslb = new LabelUTextBox();
//			
//			for (int j = 0; j < yearNumbers.length; j++) {
//				yearNumberslb.addItem(""+yearNumbers[j].getNumber(), ""+yearNumbers[j].getId());
//				
//				//wybieramy odpowiedni year numbers
//				if (yearNumberID == yearNumbers[j].getId()) {
//					yearNumberslb.setSelectedIndex(j);
//				}
//			}
//			
//			
//			
//			
//			ft.setWidget(i, 0, studiesTypeslb);
//			ft.setWidget(i, 1, semesterTypeslb);
//			ft.setWidget(i, 2, yearNumberslb);
//		}
//		
//		
//		addRecordButton.addClickListener(new ClickListener(){
//			public void onClick(Widget sender) {
//				int rowCount = ft.getRowCount();
//				
//				LabelUTextBox lb = new LabelUTextBox();
//				//ListBox lb = new ListBox();
//				
//				CSAcademicTitleDTO[] ats = Cache.getAllAcademicTitles();
//				for (int j = 0; j < ats.length; j++) {
//					lb.addItem(ats[j].getTitle(), ""+ats[j].getId());
//				}
//				
//				
//				ft.setWidget(rowCount, 0, lb);
//				ft.setWidget(rowCount, 1, new Label("name"));
//				ft.setWidget(rowCount, 2, new Label("surname"));				
//			}
//		});
//		add(addRecordButton);
		
		
		
	}

	
	
	
	private SemestersList getInstance() {
		return this;
	}

}
